#include "playlistquerymodel.h"
#include "util.h"

#include <QStringList>
#include <QVariant>

QVariant PlayListQueryModel::headerData(int section, Qt::Orientation, int role) const
{
    QStringList headers;

    headers << "" << "Title" << "Artist" << "Album" << "Lenght" << "Path";
    if (role == Qt::DisplayRole)
    {
        return headers[section];
    }

    return QVariant();
}

QVariant PlayListQueryModel::data(const QModelIndex &index, int role) const
{
    return ((index.isValid() && role == Qt::DisplayRole && index.column() == 4)
            ? calculateLength(QSqlQueryModel::data(index, role).toInt())
            : QSqlQueryModel::data(index, role));
}

PlayListQueryModel::PlayListQueryModel(QObject *parent)
        : QSqlQueryModel(parent)
{
}
